<?php

include 'functions.php';

$sites = array(
	'phptut' => array(
		'url' => "http://php.tut/curl_login2.php",
		'post' => 'username=qqq'),
	'li' => array(
		'url' => 'http://www.liveinternet.ru/stat/',
		'post' => 'rnd=%s&url=http://nasutkiorsha.by&password=searchlr&ok=OK',
		/*
		    rnd:915295623
			url:http://tut.by/
			password:555
			ok: OK
		 */
	),
	'mts' => array(
//		'url' => 'https://ihelper.mts.by/SelfCare/',
		'url' => 'https://ihelper.mts.by/SelfCarePda/',
		'url2' => 'https://ihelper.mts.by/SelfCarePda/Security.mvc/LogOn?returnLink=https%3A%2F%2Fihelper.mts.by%2FSelfCarePda%2FHome.mvc',
		'post' => 'username:295985948&password:2652301',
	),
	'onliner' => array(
		'url' => 'https://profile.onliner.by/login',
		'post' => '',
	),
	'skladchina' => array(
		'url' => 'http://skladchina.com/ucp.php?mode=login',
		'post' => '',
		/*
		 * chapaev/searchsc
        post
        username:11
        password:22
        redirect:./ucp.php?mode=login&sid=05711a596e39f3e5dfd339431c418bfa
        sid:05711a596e39f3e5dfd339431c418bfa
        redirect:index.php
        login:����
		 */
	),

);
$site = $sites['mts'];

$hCurl = curl_init();
curl_setopt_array($hCurl, array(
	CURLOPT_URL             => 'https://ihelper.mts.by/SelfCare/',
	CURLOPT_SSL_VERIFYPEER  => false, // mts https off
	CURLOPT_SSL_VERIFYHOST  => false, // mts https off
	CURLOPT_RETURNTRANSFER  => 1,
	CURLOPT_FOLLOWLOCATION  => 1,
));

$data1 = curl_exec($hCurl);
dump($data1, 1);

/*
 * parse form extra fields - simple html dom
 */
//include 'lib/simple_html_dom.php';
//$data1 = str_get_html($data1);
curl_setopt_array($hCurl, array(
	CURLOPT_URL         => $site['url2'],
	CURLOPT_POST        => 1,
	CURLOPT_POSTFIELDS  => $site['post'],
//	    sprintf($site['post'], 1
//		$data1->find('input[name="rnd"]',0)->value, // li
//		),
	CURLOPT_COOKIEJAR   => dirname(__FILE__).'/cookie.tmp',
	CURLOPT_COOKIE      => dirname(__FILE__).'/cookie.tmp',
	CURLOPT_RETURNTRANSFER => 1,
	CURLOPT_FOLLOWLOCATION => 1,
	CURLOPT_SSL_VERIFYPEER => false, // mts https off
	CURLOPT_SSL_VERIFYHOST => false, // mts https off
));

$data2 = curl_exec($hCurl);
dump($data2);


